package A001singleton;

public class A002Singleton饿汉式03_静态代码块 {

    public static class Singleton {
        /**
         *  静态代码块
         */
        public static final Singleton INSTANCE;
        private String info;

        static {
            try {
                INSTANCE = new Singleton("123");
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
        }
        private Singleton(String info) {
            this.info = info;
        }
    }

    public static void main(String[] args) {
        System.out.println(A002Singleton饿汉式03_静态代码块.Singleton.INSTANCE == A002Singleton饿汉式03_静态代码块.Singleton.INSTANCE);
        System.out.println(A002Singleton饿汉式03_静态代码块.Singleton.INSTANCE == A002Singleton饿汉式03_静态代码块.Singleton.INSTANCE);
    }

}
